package protocol.JT808_2011;

public class Handle808_2011JT03 implements IHandle808_2011JT {

    @Override
    public String handle(JT808_2011Cmd cmd) {
        byte subOrder = cmd.subOrder();

        switch (subOrder){
            case 0x01:
                return handle0301(cmd);
            case 0x02:
                return handle0302(cmd);
            default:
                return "808-2011:未匹配的命令字"+(cmd.readOrder()+","+cmd.subOrder());
        }
    }

    private String handle0301(JT808_2011Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("终端->平台:事件报告");
        builder.append("\r\n");
        builder.append("事件ID:"+cmd.readInt(1));
        builder.append("\r\n");
        return builder.toString();
    }


    private String handle0302(JT808_2011Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("终端->平台:提问应答");
        builder.append("\r\n");
        builder.append("流水号:"+cmd.readWORD());
        builder.append("\r\n");
        builder.append("答案ID:"+cmd.readInt(1));
        builder.append("\r\n");
        return builder.toString();
    }

}
